<!DOCTYPE html>
<html style="background-color: #eaeaea21;">
<head>
<meta charset="UTF-8">
<title>会话</title>
<link rel="stylesheet" href="../layui/css/layui.css" media="all">
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../layui/layui.js"></script>

	<!-- 网页字体库 -->
	<link href="http://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i&amp;subset=devanagari,latin-ext"
	 rel="stylesheet">
	<link href="http://fonts.googleapis.com/css?family=Tangerine:400,700" rel="stylesheet">
	<link href="http://fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i&amp;subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese" rel="stylesheet">

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type="text/javascript">
	/* 获取当前用户id */
	var currentUid = 2;
	
	$(document).ready(function(){
		allSession(currentUid)
	});
	
	/* 全部会话  */
	function allSession(currentUid){
 		var options = {
    			url: "/message/getAllMessages",
    			method: 'post',
    			data:{
    				uid:currentUid
    			},
			    success: function (data) {
			    	console.info(data);
  			    	var po1 = "";
			    	for (var i = 0; i < data.length; i++) {
			    			po1 += '<div class="layui-card" style="box-shadow: 0px 0px 0px 6px rgba(2, 2, 2, 0.07);margin-top: 20px;height: 88px;">'
				    			+'<div hidden>'+data[i].uid+'</div>'
				    			+'<div hidden>'+data[i].talker+'</div>'
				    			+'<div style="float: left;width: 10%;height: 100%;line-height: 75px;text-align: center;">'
				    			+'<div style="background-color: #e8e8e8;border-radius: 50%;width: 75px;height: 75px;margin-top: 6px;margin-left: 6px;">'
				    			+'头像'
				    			+'</div>'
				    			+'</div>'
				    			+'<div style="float: right;width: 88%;height: 100%;">'
				    			+'<div class="layui-card-header">'
				    			+'<span>'+data[i].nickName+'</span>'
				    			+'<span style="float: right;color: #888;">'+data[i].createDate+'</span>'
				    			+'</div>'
				    			
				    			+'<div>'
				    			
				    			+'<div class="layui-card-body" style="color: #888;width: 80%;float: left;">'+data[i].content+'</div>'
				    			
				    			+'<div style="float: right;line-height: 42px;margin-right: 16px;">'
				    			+'<form action="/chat/chatWindow">'
				    			+'<input type="hidden" name="talkerUid" value="'+data[i].uid+'">'
				    			+'<input type="hidden" name="currentUid" value="'+data[i].talker+'">'
				    			+'<input type="submit" class="layui-btn layui-btn-sm layui-btn-normal" value="查看">'
				    			+'</form>'
				    			+'</div>'

				    			+'</div>'
				    			
				    			+'</div>'
				    			+'</div>';
					}
			    	$("#contents").html(po1);
			    }
    	};
    	$.ajax(options);
	}
	//获取选择行
	function getThisRow(element){
		uid = element.children[0].innerHTML;
		talker = element.children[1].innerHTML;
		//alert(t1+":"+t2);
		var options = {
    			url: "/chat/chatWindow",
    			method: 'get',
    			data:{
    				talkerUid:uid,
    				currentUid:talker
			    },
			    success: function (data) {
			    	console.info(data);
			    }
    	};
    	$.ajax(options); 
	}
	
	
</script>
</head>
<body>



<div class="layui-container" style="width: 60%;height: 720px;">

		<!-- 导航栏 -->
		<ul class="layui-nav">
		  <li class="layui-nav-item">
		   <!-- 	<a href="../home.jsp" id="totle">Yoga</a> -->
		   	<a href="../home.jsp" style="font-family: 'Tangerine', cursive;font-size: 100%;color:white;">Yoga</a>
		  </li>
		  <li class="layui-nav-item" style="float: right;">
		    <a href="#" onClick="javascript :history.back(-1);">返回</a>
		  </li>
		</ul>

	<!-- header -->
	<div style="margin-bottom: 15px;">
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			<legend>会话</legend>
		</fieldset>
	</div>
	<div id="contents">
		<!-- 内容 -->
	</div>
	
</div>






	<!-- demo -->
<!-- 	<form action="/chat/chatWindow">
		<h2>会话</h2>
		
		测试
			需获取当前登录用户id和聊天对象用户id，才能开启聊天
		
		模拟获取聊天对象用户id
		<input type="hidden" name="talkerUid" value="2">
		
		模拟获取当前登录用户id${user.uid}
		<input type="hidden" name="currentUid" value="1">
		
		<input type="submit" value="发送消息">
	</form> -->
	
</body>
</html>